/**
 * 
 */
package profile.report;

import java.util.ArrayList;
import java.util.Collection;
import java.util.List;

/**
 * @author ductrung.tran
 *
 */
public class MethodCompareReport {

	/*private String availableVersion = "";
	private Collection<ParamResultReport> paramTestResultReports;
	
	private List<CompareResultItem> resultItems = new ArrayList<CompareResultItem>();
	
	public void available(String version) {
		this.availableVersion = version;
	}

	public void setParamResultReports(Collection<ParamResultReport> paramTestResultReports) {
		this.paramTestResultReports = paramTestResultReports;
	}*/

	private List<ParamCompareReport> paramCompareReports = new ArrayList<ParamCompareReport>();
	
	public void addCommonParamCompareReport(
			ParamResultReport firstParamResultReport,
			ParamResultReport secondParamResultReport) {
		ParamCompareReport report = new ParamCompareReport(firstParamResultReport.getParam(), firstParamResultReport, secondParamResultReport);
		paramCompareReports.add(report);
		
		/*double overheadExec = (secondParamTestResultReport.getAvgExecTime() - firstParamTestResultReport.getAvgExecTime()) / firstParamTestResultReport.getAvgExecTime();
		double overheadCorba = (secondParamTestResultReport.getAvgCorbaTime() - firstParamTestResultReport.getAvgCorbaTime()) / firstParamTestResultReport.getAvgCorbaTime();
		double overheadServer = (secondParamTestResultReport.getAvgServerTime() - firstParamTestResultReport.getAvgServerTime()) / firstParamTestResultReport.getAvgServerTime();
		
		CompareResultItem item = new CompareResultItem();
		item.setParam(firstParamTestResultReport.getParam());
		item.setOverheadExec(overheadExec);
		item.setOverheadCorba(overheadCorba);
		item.setOverheadServer(overheadServer);
		
		resultItems.add(item);*/
		
	}

	public void addOtherParamReports(
			Collection<ParamResultReport> first,
			Collection<ParamResultReport> second) {
		
		ParamCompareReport report = new ParamCompareReport(first, second);
		paramCompareReports.add(report);
		/*double[] totalFirst = getTotal(first);
		double[] totalSecond = getTotal(second);
		
		double overheadExec = (totalSecond[0] - totalFirst[0]) / totalFirst[0];
		double overheadCorba = (totalSecond[1] - totalFirst[1]) / totalFirst[1];
		double overheadServer = (totalSecond[2] - totalFirst[2]) / totalFirst[2];
		
		CompareResultItem item = new CompareResultItem();
		item.setParam("GROUPED");
		item.setOverheadExec(overheadExec);
		item.setOverheadCorba(overheadCorba);
		item.setOverheadServer(overheadServer);
		
		resultItems.add(item);*/
		
	}

	public List<ParamCompareReport> getParamCompareReports() {
		return paramCompareReports;
	}
	
	/*private double[] getTotal(Collection<ParamResultReport> reports) {
		double[] total = new double[] {0,0,0};
		for (ParamResultReport report : reports) {
			total[0] += report.getAvgExecTime();
			total[1] += report.getAvgCorbaTime();
			total[2] += report.getAvgServerTime();
		}
		
		return total;
	}

	public String getAvailableVersion() {
		return availableVersion;
	}
	
	public boolean isMissing() {
		return !availableVersion.equals("");
	}
	
	public Collection<ParamResultReport> getParamTestResultReports() {
		return paramTestResultReports;
	}

	public List<CompareResultItem> getResultItems() {
		return resultItems;
	}

	@Override
	public String toString() {
		return isMissing() ? availableVersion + ", " + paramTestResultReports :
			resultItems.toString();
	}*/
	
	

}
